package shortlink.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import shortlink.common.convention.result.Result;
import shortlink.common.convention.result.Results;
import shortlink.remote.ShortLinkRemoteService;
import shortlink.remote.dto.req.RecycleBinRecoverReqDTO;
import shortlink.remote.dto.req.RecycleBinRemoveReqDTO;
import shortlink.remote.dto.req.RecycleBinSaveReqDTO;
import shortlink.remote.dto.req.ShortLinkRecycleBinPageReqDTO;
import shortlink.remote.dto.resp.ShortLinkPageRespDTO;
import shortlink.service.RecycleBinService;

@RestController
@RequiredArgsConstructor
public class RecycleBinController {
    private final ShortLinkRemoteService shortLinkRemoteService;
    private final RecycleBinService recycleBinService;

    /*保存至回收站*/
    @PostMapping("/api/short-link/admin/link/SaveRecycleBin")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveReqDTO requestParam) {
        shortLinkRemoteService.saveRecycleBin(requestParam);
        return Results.success();
    }
    /*恢复短链接*/
    @PostMapping("/api/short-link/preoject/link/RecoverRecycleBin")
    public Result<Void> recoverRecycleBin(@RequestBody RecycleBinRecoverReqDTO requestParam) {
        shortLinkRemoteService.recoverRecycleBin(requestParam);
        return Results.success();
    }
    /*移除短链接*/
    @PostMapping("/api/short-link/preoject/link/RemoveRecycleBin")
    public Result<Void> removeRecycleBin(@RequestBody RecycleBinRemoveReqDTO requestParam) {
        shortLinkRemoteService.removeRecycleBin(requestParam);
        return Results.success();
    }
    /*分页查询回收站短链接*/
    @GetMapping("/api/short-link/preoject/link/PageRecycleBin")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleBinShortLink(ShortLinkRecycleBinPageReqDTO requestParam) {
        return recycleBinService.pageRecycleBinShortLink(requestParam);
    }
}
